package com.itheima.health.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Set;

@Mapper
public interface UserMapper extends BaseMapper<User> {


    @Select("select * from t_user where username = #{username}")
    UserVO findUserByUsername(@Param("username") String username);

    @Select("select tr.* from t_role tr, t_user_role tur where tr.id = tur.role_id and tur.user_id = #{uid}")
    Set<RoleVO> findRolesByUid(@Param("uid") Integer id);

    @Select("select tp.* from t_permission tp, t_role_permission trp where tp.id = trp.permission_id and trp.role_id = #{id}")
    Set<Permission> findPermssionsByRoleId(@Param("id")Integer id);
}
